package cn.wubo.config.controller;

import cn.wubo.config.entity.OtherPerson;
import cn.wubo.config.entity.Person;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@EnableConfigurationProperties({Person.class,OtherPerson.class})
public class testConfigController {

    @RequestMapping("/test1")
    public String test1(){
        return "测试配置文件";
    }

    @Value("${personinfo.addString}")
    private String str1;
    @Value("默认值哦")
    private String str2;

    @RequestMapping("/test2")
    public String test2(){
        return str1 + str2;
    }

    @Autowired
    Person person;

    @RequestMapping("/test3")
    public Person test3(){
        return person;
    }

    @Autowired
    OtherPerson otherPerson;

    @RequestMapping("/test4")
    public String test4(){
        return otherPerson.getName() + otherPerson.getItem() + otherPerson.getFix();
    }
}
